<template>
    <main-wrap :loading="true" :load="getList" :end="finished" :overText="lists.length==0 ? ' ':''">
        <template v-slot:header>
            <my-search v-model.trim="searchParams.keyword" @serach="doSearch" icon="" placeholder="请输入关键字搜查"/>
        </template>
        <ul class="mList">
            <li v-for="dt in lists" :key="dt.moment_id">
                <a>
                    ggg
                </a>
            </li>
        </ul>
        <van-empty  v-if="lists && lists.length==0" description="暂无数据" />
        <template v-slot:footer>
            <RouterLink class="cjbtnbox" :to="{name:'MeetingAdd'}">
                <van-button type="primary" round color="#e3af2f" block>创建会议</van-button>
            </RouterLink>
        </template>
    </main-wrap>
</template>
<script setup>
import { ref,onMounted,nextTick } from "vue";
import {useRouter} from 'vue-router'
import moment from 'moment'
import Image from "@/components/image.vue"
import {get_meetings_list} from '@/api/qy-wechat-api'
import {toast,loading,clearToast} from '@/utils/vant'
import { useUserStore } from '@/stores/modules/user'
import mainWrap from '@/components/mainWrap.vue'
import footerNav from '@/components/footerNav.vue'
//import smSearch from "./components/smSearch.vue"
import mySearch from '@/components/mySearch.vue'
import {timestampFormat} from '@/utils/convert'

const router = useRouter()
const userStore = useUserStore()

const lists = ref('')
let pageSize = 20
let cursor = ref('') // 腾讯接口游标
const searchParams = ref({}) // isUsable:true只看可用的客户（即没有删除的用户）
const finished = ref(false)
const today = ref('')
const member_userid = ref('') // 成员id

onMounted(async ()=>{
    today.value = moment().format('YYYY-MM-DD')
    const {currentRoute} = router
    member_userid.value = currentRoute.value.query.userid || userStore.userInfo.userid
    getList()
})


const getList = async ()=>{
    const preDate = moment().subtract(30, 'days').format('YYYY-MM-DD'); //将当前日期减去30天
    const nextDate = moment().subtract(-30, 'days').format('YYYY-MM-DD'); //将当前日期加上30天
    //console.log('modifiedDate:',preDate,nextDate)
    return new Promise((resolve, reject) => {
        setTimeout(async () => {
            const res = await get_meetings_list({
                userid:member_userid.value,
                begin_time:moment(preDate).unix(),
                end_time:moment(nextDate).unix(),
                cursor:cursor.value,
                limit:pageSize,
            })
            lists.value = [...lists.value, ...res.data.meetingid_list];
            cursor.value = res.data.next_cursor
            if (lists.value && !res.data.next_cursor) {
              finished.value = true;
            }
            resolve(true);
        }, 500);
    });
}

const doSearch = (obj)=>{
    
}

</script>

<style lang="scss" scoped>
.mList{
    padding: 10px 0 0 0;
    margin: 0;
    list-style: none;
    li{
        padding: 0 0 10px 0;
        a{
            display: block;
            background-color: #fff;
            padding: 20px;
           
        }
    }
}
.cjbtnbox{
    display: block;
    padding: 10px 20px;
    background-color: #fff;
    box-shadow: 0 0 5px #eee;
}

</style>